<%@ page import="com.hrm.entity.EmployeeEntity" %>
<%@ page import="com.hrm.entity.InfoEntity" %>
<%@ page import="com.hrm.dto.Envelope" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.hrm.entity.AdminEntity" %><%--
  Created by IntelliJ IDEA.
  User: zekdot
  Date: 20-3-11
  Time: 下午11:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%--<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/table.css">--%>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <link href="${pageContext.request.contextPath}/css/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
    Map<String,Object> map = (Map<String, Object>) request.getAttribute("param");
    EmployeeEntity employeeEntity = (EmployeeEntity) map.get("employee");
    InfoEntity infoEntity = (InfoEntity) map.get("info");
%>
<%
    if(employeeEntity != null){
%>
<div class="div_form">
    <h1 class="h1_style"><i class="i_h1"></i> 内容填写</h1>
    <%--<form id="form_demo" >--%>
        <p class="form_p"><label class="form_label">id：</label>
            <input type="text" class="form_input readonly" readonly="readonly" value="<%=employeeEntity.getId()%>">
            </p>
        <p class="form_p"><label class="form_label">姓名：</label>
            <input type="text" class="form_input " id="name" minlength="2"
                   value="<%=infoEntity.getName()%>">
        </p>
        <p class="form_p"><label class="form_label">性别：</label>
            <select id="gender" class="form_input1">
                <option value="男" <%=infoEntity.getGender().equals("男")?"selected":""%>>男</option>
                <option value="女" <%=infoEntity.getGender().equals("女")?"selected":""%>>女</option>
            </select>
        </p>

        <p class="form_p"><label class="form_label">年龄：</label>
            <input type="text" class="form_input " id="age" minlength="2"
                   value="<%=infoEntity.getAge()%>">
        </p>
        <p class="form_p"><label class="form_label">联系方式：</label>
            <input type="text" class="form_input " id="contact" minlength="2"
                   value="<%=infoEntity.getContact()%>">
        </p>
        <p class="form_p"><label class="form_label">部门：</label>
            <input type="text" class="form_input readonly" readonly="readonly"
                   value="<%=employeeEntity.getDepartment()%>">
        </p>
        <p class="form_p"><label class="form_label">职位：</label>
            <input type="text" class="form_input readonly" readonly="readonly"
                   value="<%=employeeEntity.getPosition()%>">
        </p>
        <p class="form_p"><label class="form_label">状态：</label>
            <input type="text" class="form_input readonly" readonly="readonly"
                   value="<%=employeeEntity.getStatus()==0?"在职":"离职"%>">
        </p>
        <p class="form_p"><label class="form_label">政治面貌：</label>
            <select id="polity" class="form_input1">
                <option value="党员" <%=infoEntity.getPolity().equals("党员")?"selected":""%>>党员</option>
                <option value="群众" <%=infoEntity.getPolity().equals("群众")?"selected":""%>>群众</option>
                <option value="无党派人士" <%=infoEntity.getPolity().equals("无党派人士")?"selected":""%>>无党派人士</option>
            </select>
        </p>
        <p class="form_p"><label class="form_label">民族：</label>
            <input type="text" class="form_input " value="<%=infoEntity.getNation()%>"
                   id="nation" minlength="2">
        </p>
        <p class="form_p"><label class="form_label">文化程度：</label>
            <select id="education" class="form_input1">
                <option value="小学" <%=infoEntity.getEducation().equals("小学")?"selected":""%>>小学</option>
                <option value="初中" <%=infoEntity.getEducation().equals("初中")?"selected":""%>>初中</option>
                <option value="高中" <%=infoEntity.getEducation().equals("高中")?"selected":""%>>高中</option>
                <option value="本科" <%=infoEntity.getEducation().equals("本科")?"selected":""%>>本科</option>
                <option value="硕士" <%=infoEntity.getEducation().equals("硕士")?"selected":""%>>硕士</option>
                <option value="博士" <%=infoEntity.getEducation().equals("博士")?"selected":""%>>博士</option>
            </select>
        </p>
        <p class="form_p"><label class="form_label">毕业院校：</label>
            <input type="text" class="form_input " value="<%=infoEntity.getGraduation()%>" id="graduation"
                   minlength="2">
        </p>
        <p class="form_p"><label class="form_label">籍贯：</label>
            <input type="text" class="form_input " value="<%=infoEntity.getOrigin()%>" id="origin"
                   minlength="2">
        </p>
        <p class="form_p"><label class="form_label">入职日期：</label>
            <input type="text" class="form_input readonly" readonly="readonly"
                   value="<%=infoEntity.getInDate()%>">
        </p>
        <p class="form_p"><label class="form_label">离职日期：</label>
            <input type="text" class="form_input readonly" readonly="readonly"
                   value="<%=infoEntity.getOutDate().equals("")?"未离职":infoEntity.getOutDate()%>">
        </p>
        <p class="but_p">
            <input type="button" value="保存" class="but_save" id="sub"/>
        </p>
        <p class="but_p">
            <button class="but_save" onclick="location.href='${pageContext.request.contextPath}/employee/editSalaryPage?id=<%=employeeEntity.getId()%>'">薪水管理</button>
                <%
                if(session.getAttribute("user").getClass() != AdminEntity.class){
                %>
                <button class="but_save"  onclick="location.href='${pageContext.request.contextPath}/employee/posPage?id=<%=employeeEntity.getId()%>'">职位调动</button>

                <%
                    }
                %>
        </p>
    <%--</form>--%>
</div>




<script>
    function checkOrigin(str){
        if(str.indexOf('市') == -1)  

        return false;
        if(str.indexOf('县') == -1 && str.indexOf('区') == -1)
            return false;
        return true;
    }

    $('#sub').click(function(){
        if($('#contact').val().length != 11){
           alert('请输入合法的联系方式');
           return;
        }
        if(!checkOrigin($('#origin').val())){
           alert('请输入合法的籍贯');
           return;
        }

        var paramJson = {'name':$('#name').val(),'gender':$('#gender').val(),'age':$('#age').val(),
        'contact':$('#contact').val(),'polity':$('#polity').val(),'nation':$('#nation').val(),
        'education':$('#education').val(),'graduation':$('#graduation').val(),'origin':$('#origin').val()};
        paramJson = JSON.stringify(paramJson);
        var data = {'id':'<%=infoEntity.getEId()%>','paramJson':paramJson};
        $.post('updateInfo',data,function(str){
           var res = eval('(' + str +')');
           if(res.code != 0){
               alert(res.message);
               return;
           }
           location.href = location.href;
        });
    });
</script>
<%
    }
%>

</body>
</html>
